/**
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function (root) {
	// 空树返回真
	if (!root) {
		return true;
	}
	const check = (left, right) => {
		if (!left && !right) {
			return true;
		}
		if (!left || !right) {
			return false;
		}
		if (left.val !== right.val) {
			return false;
		}
		return check(left.left, right.right) && check(left.right, right.left)
	}
	return check(root.left, root.right);
}